<?php

namespace app\home\controller;

use app\common\model\Category;
use app\common\model\Config;
use think\Controller;
use app\traits\Home;
use app\admin\model\Banner as BannerModel;

class Base extends Controller
{
    use Home;

    //引入trait

    function _initialize()
    {
//        banner
        $banners = BannerModel::where("languagedata", "0")->select();
        $Banner = [];
        foreach ($banners as $v) {
            $Banner[$v['category_id']] = $v['image'];
        }
        //        类别
        $Cate = Category::where('pid', '0')->select();
        $CateName = [];
        foreach ($Cate as $v) {
            $CateName[$v['type']][] = $v; // "product"=>[ [],[] ]
        }
        //halt($CateName['product']);
//        杂项
        $sundryS = Config::where('group', 'basic')->select();
        $sundry = [];
        foreach ($sundryS as $v) {
            $sundry[$v['name']] = $v['value'];
        }
        $this->assign([
            'CateName' => $CateName,
            'Banner' => $Banner,
            'menu' => '',
            'sundry' => $sundry,
        ]);
    }
}